<?php

declare(strict_types=1);

namespace app\service\dto;

/**
 * 登录成功结果类
 */
class LoginSuccessResult extends SuccessResult
{
    private string $accessToken;
    private string $refreshToken;
    private string $expires;
    private string $username;
    private string $nickname;
    private array $roles;
    private array $permissions;
    private array $menus;
    private array $profile;
    private array $identities;
    private array $gatewayGroups;
    private string $client;

    public function __construct(
        string $accessToken,
        string $refreshToken,
        string $expires,
        string $username,
        string $nickname,
        array $roles,
        array $permissions,
        array $menus,
        array $profile = [],
        array $identities = [],
        array $gatewayGroups = [],
        string $client = 'admin'
    ) {
        $this->accessToken = $accessToken;
        $this->refreshToken = $refreshToken;
        $this->expires = $expires;
        $this->username = $username;
        $this->nickname = $nickname;
        $this->roles = $roles;
        $this->permissions = $permissions;
        $this->menus = $menus;
        $this->profile = $profile;
        $this->identities = $identities;
        $this->gatewayGroups = $gatewayGroups;
        $this->client = $client;

        parent::__construct([], '登录成功', 200);
    }

    public function getData(): array
    {
        return [
            'accessToken' => $this->accessToken,
            'refreshToken' => $this->refreshToken,
            'expires' => $this->expires,
            'username' => $this->username,
            'nickname' => $this->nickname,
            'roles' => $this->roles,
            'permissions' => $this->permissions,
            'menus' => $this->menus,
            'profile' => $this->profile,
            'identities' => $this->identities,
            'gatewayGroups' => $this->gatewayGroups,
            'client' => $this->client,
            'partial' => false
        ];
    }
}
